package com.qcs.sleep.call;

import java.util.Observable;
import java.util.Observer;

/**
 * Created by chshqiang on 15-7-21.
 * 用于通知所有的 Observer
 */
public class ActionChanger extends Observable {
    private static final ActionChanger ACTION_CHANGER = new ActionChanger();

    private ActionChanger() {
    }

    public static ActionChanger getInstance() {
        return ACTION_CHANGER;
    }

    public void send(String action) {
        setChanged();
        notifyObservers(action);
    }

    @Override
    public void addObserver(Observer observer) {
        if (observer instanceof ActionWatcher)
            super.addObserver(observer);
    }

    @Override
    public synchronized void deleteObserver(Observer observer) {
        if (observer instanceof ActionWatcher)
            super.deleteObserver(observer);
    }
}
